package com.business.java2cache.core;

import com.business.java2cache.util.CacheException;

/**
 * Implementors define a caching algorithm. All implementors
 * <b>must</b> be threadsafe.
 */
public interface Cache {
    /**
     * Get an item from the cache
     *
     * @param region cache region
     * @param key    cache key
     * @return the cached object or null
     */
    public Object get(String region, String key) throws CacheException;

    /**
     * Add an item to the cache
     * failfast semantics
     *
     * @param region
     * @param key     cache key
     * @param value   cache value
     * @param seconds cache Expiration time
     */
    public void set(String region, String key, Object value, int seconds) throws CacheException;

    /**
     * @param key Cache key
     *            Remove an item from the cache
     */
    public void remove(String region, Object key) throws CacheException;

    /**
     * Clear the cache
     */
    public void clear(String region) throws CacheException;

    /**
     * update exprie time
     *
     * @param key
     * @param seconds
     */
    public Object exprie(String region, String key, int seconds);

}
